package com.ziven.common.widget.alphabet;

import android.text.TextUtils;

import androidx.annotation.NonNull;

import com.ziven.easygo.util.Carry;
import com.ziven.easygo.util.EasyUtils;

/**
 * @author Ziven
 */
final class ToPinyinUtil {

    public static final String EMPTY = "#";

    private ToPinyinUtil() {}

    /**
     * null or "" return {@link EasyUtils#EMPTY}
     * @param string String
     * @return Trim String
     */
    @NonNull
    public static String trim(String string) {
        if(TextUtils.isEmpty(string)) {
           return EasyUtils.EMPTY;
        }
        string = string.trim();
        if(TextUtils.isEmpty(string)) {
            return EasyUtils.EMPTY;
        }
        return string;
    }

    public static String empty(String string) {
        return TextUtils.isEmpty(string)
                ? EasyUtils.EMPTY
                : string;
    }

    public static <T> T carry(T data, @NonNull Carry<T> carry) {
        carry.carry(data);
        return data;
    }
}
